-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fs: reduced duplicate code in fs.write() #2947
Conversation
LGTM |
Amusingly btw, the names for strWrapper and bufWrapper were reversed:
Anyway, that doesn't matter anymore as they've been unified now. |
I think this was actually done on purpose to avoid polymorphism |
@vkurchatkin Could you please elaborate? |
@thefourtheye FWIW this blog post explains mono/poly/mega-morphism (how it relates to v8/JavaScript) pretty well. |
Correct me if I'm wrong: |
After looking at FSWrapReq, it looks like the function arguments are always the same types for a write operation, so I think @meinklaus is right here. |
Any blockers? |
LGTM if the CI is happy. For the record, I don't even know if keeping a reference to the string is necessary ("external" strings? this isn't handled elsewhere afaik). |
I don't know either to be honest. @trevnorris may know more on this. I don't see that as a blocker for this PR, but if we can get clarity on that, of course I can update the PR if needed. I wouldn't want to introduce risk though. |
IIRC you had a fix like this before. LGTM. I'm the one who did it this way. Was b/c I was overly strict about where I placed that assignment. Wasn't actually needed. |
In the previous PR it was about buffers, this time it's about a string (well, the conversation is). Are you saying I can remove |
I'm on crack. Was referring to changing the location of As for maintaining a reference to the string, when the string is externalized a reference has to be kept. Since we used the external memory from the string object. So if the string is GC'd while the data is written it can blow up. |
Got it, thanks. Sounds like we're all good then :) |
Yup. LGTM |
Looking forward to seeing it merged :) Anything I can do to speed that up? |
Whoops. Sorry. Running CI to verify everything is fine: https://ci.nodejs.org/job/node-test-pull-request/627/ |
PR-URL: #2947 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Bugger. NM. Landed in c339fa3. Thanks much! |
@trevnorris @thefourtheye @vkurchatkin ... should this also go into v4.x? |
@jasnell code cleanup, no bug fix but also no side-effects. might be useful to have if landing future patches in the same code in the future. |
PR-URL: #2947 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Landed in v4.x-staging in fb3b848 |
PR-URL: nodejs#2947 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
PR-URL: #2947 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
No description provided.